package com.karaku.karaku_collector.common;

import java.util.HashMap;

/**
 * Created by guoping on 2017/4/24.
 */

public abstract class BaseApi {

    public static HashMap<String, String> createParams(Object...paramKeyValues) {
        if (paramKeyValues != null && paramKeyValues.length % 2 != 0) {
            throw new IllegalArgumentException("param error");
        }

        HashMap<String, String> params = new HashMap<>();
        if (paramKeyValues != null) {
            for (int i = 0; i < paramKeyValues.length; i += 2) {
                Object value = paramKeyValues[i + 1];
                params.put(paramKeyValues[i].toString(), value == null ? "" : value.toString());
            }
        }
        addBaseParams(params);
        return params;
    }

    private static void addBaseParams(HashMap<String, String> inParams) {
        inParams.put("skipAuth", "true");
        inParams.put("timestamp", String.valueOf(System.currentTimeMillis()));
    }
}
